<?php include '_init_.php';?>
<?php
$act = isset($_REQUEST['act'])?$_REQUEST['act']:'';
$dt = new DataTable(constant('DB_TABLE_GIFT'));
if($act == 'save')
{
	$data = $_REQUEST;
	if(intval($data['id']) < 1)
	{
		unset($data['id']);
	}
	if(strlen($data['name']) > 0)
		$data['sort_index'] = intval(substr($data['name'],0,1));
	$data['price'] = floatVal($data['price']);
	$dt->save($data);
	AppMain::refreshParentFrame();
}
if($act == 'edit')
{
	$info = $dt->get(intval($_REQUEST['id']));
}
if($act == 'new')
{
	$info = array('id'=>'','name'=>'','price'=>'');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/formvalidate.js"></script>
</head>

<body>
<form method="post">
<input type="hidden" name="act" value="save"/>
<input type="hidden" name="id" value="<?php echo $info['id'];?>"/>
<div class="mainf-8">
  <ul>
   <li class="article-1c">
     名稱
    <input name="name" type="text" class="maine-keyina" value="<?php echo $info['name'];?>"/></li>
    <li class="article-1c">
     價格
    <input name="price" type="text" class="maine-keyina _validate_form_float" value="<?php echo $info['price'];?>"/></li>
  </ul>

</div>
<div class="mainf-7">
<ul>
<li class="article-1g"><input name="" type="button" class="article-1a_btn" value="儲存" onclick="this.form.submit();"/></li>
</ul>
</div>
</form>
</body>
</html>
